﻿using System;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Printing;
using Microsoft.Reporting.WebForms;
using HiauPdm.Bll;
using HiauPdm.Web;

namespace HiauPdm.Web
{
    public partial class Jsc_WebPrint : PageBase
    {
        protected override bool IsAccess()
        {
            return true;
        }

        /// <summary>
        /// 加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) { return; }
            ReportViewer1.ShowExportControls = (Request.QueryString["sExport"] == "1");
            //if (Request.QueryString["sPrint"] == "2")
            //{
            //    ReportViewer1.ShowPrintButton = false;
            //    Page.ClientScript.RegisterClientScriptBlock(GetType(), "ShowPrint", "window.attachEvent('onload',function(){ShowPrint();});", true);
            //}
            ReportViewer1.LocalReport.ReportPath = string.Format(@"WebApp\Report\{0}", Request.QueryString["sReport"]);
            DataSet ds = null;
            if (Request.QueryString["sP0"] == null)
                ds = BMain.GetDataSet(ReportViewer1.LocalReport.GetParameters()["SQLText"].Values[0]);
            else if (Request.QueryString["sP1"] == null)
                ds = BMain.GetDataSet(ReportViewer1.LocalReport.GetParameters()["SQLText"].Values[0], Request.QueryString["sP0"]);
            else
                ds = BMain.GetDataSet(ReportViewer1.LocalReport.GetParameters()["SQLText"].Values[0], Request.QueryString["sP0"], Request.QueryString["sP1"]);
            ReportDataSource rDs = new ReportDataSource("DataSet1", ds.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Add(rDs);
            ReportViewer1.LocalReport.Refresh();
        }
    }
}